﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSnsRoleSimple.cpp
//    @Author           :    gaoyi
//    @Date             :    2025-03-26
//    @Email			:    445267987@qq.com
//    @Module           :    NFSnsRoleSimple
//
// -------------------------------------------------------------------------

#include "NFSnsRoleSimple.h"

#include "NFTransSaveSimpleDb.h"

#define EXPIRE_TIME_SEC 300      // 过期时间 300 秒
#define CREATE_TIMEOUT_SEC 300   // 创建后过期时间 300 秒

NFSnsRoleSimple::NFSnsRoleSimple()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFSnsRoleSimple::~NFSnsRoleSimple()
{
}

int NFSnsRoleSimple::CreateInit()
{
    return 0;
}

int NFSnsRoleSimple::ResumeInit()
{
    return 0;
}

int NFSnsRoleSimple::SendTransToDb(int iReason)
{
    NFTransSaveSimpleDb* pTrans = NFTransSaveSimpleDb::CreateTrans();
    CHECK_NULL_WF(GetRoleId(), pTrans, "CreateTrans failed, NFTransSaveSimpleDb used num:{} all num:{}", NFTransSaveSimpleDb::GetStaticUsedCount(), NFTransSaveSimpleDb::GetStaticItemCount());
    int iRetCode = pTrans->SaveDb(this, iReason);
    CHECK_ERR_AND_FIN_TRANS(iRetCode, pTrans, "SaveDb failed, iReason:{}", iReason);
    return 0;
}

int NFSnsRoleSimple::InitData(const Proto_RoleSimpleInfo& info)
{
    m_stData.role_info = info;
    return 0;
}

int NFSnsRoleSimple::InitData(NFSnsRoleSimple* pRoleSimple)
{
    CHECK_NULL(0, pRoleSimple);
    m_stData = pRoleSimple->m_stData;
    return 0;
}

int NFSnsRoleSimple::MakeInitData(proto_ff::Proto_RoleSimpleInfo& info, uint64_t roleId)
{
    info.set_role_id(roleId);
    info.set_level(1);
    return 0;
}
